package org.example.service.impl;

import org.example.dao.UserDao;
import org.example.pojo.User;
import org.example.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service("userService")
//@Component("userService")
@Scope("prototype")
public class UserServiceimpl  implements UserService {
    @Resource//该注解代表依赖注入
    // @Autowired按类型注入
    private UserDao userDao;
    @Value("${name}")
    String name;
    @Override
    public void Save() {
        User user=new User();
        user.setName("张三");
        user.setAge(18);
        user.setId("11212");
        user.setSex("男");
        userDao.Save(user);
        System.out.println("UserService启动成功"+name);
    }
}
